<template>
	<view class="gsz">
		<view class="top-warp">
			<view class="top-box">
				<view class="">
					<view class="">我的共生值</view>
					<view class="t">
						{{ user.score }}
					</view>
				</view>
			</view>
			<view class="top-bottom">
				<view class="btn" @click="$wanlshop.auth('/pages/gsz/tx')">
					<image class="tb" src="@/static/images/tx.png" mode=""></image>
					提现
				</view>
				<view class="lin"></view>
				<view class="btn" @click="$wanlshop.auth('/pages/gsz/zz')">
					<image class="tb" src="@/static/images/zz.png" mode=""></image>
					转账
				</view>
			</view>
		</view>
		<view class="bottom" v-if="list.length > 0">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view class="title">
					<view class="">{{ item.memo }}</view>
					<view class="num">{{ item.score > 0 ? `+${item.score}` : item.score }}</view>
				</view>
				<view class="date">{{ $wanlshop.timeFormat(item.createtime, 'yyyy-mm-dd hh:MM') }}</view>
			</view>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {
			num: 0,
			list: [],
			pages: 1,
			loading: false
		};
	},
	computed: {
		...mapState(['common', 'user'])
	},
	onLoad(e) {
		this.getDate();
	},
	async onReachBottom() {
		console.log('onReachBottom');
		if (this.loading) {
			this.pages++;
			this.getDate();
		}
	},
	methods: {
		getDate() {
			uni.request({
				url: `/wanlshop/user/scoreLog?page=${this.pages}`,
				method: 'POST',
				success: (res) => {
					if (res.data.last_page > this.pages) {
						this.loading = true;
					} else {
						this.loading = false;
					}
					this.list = this.list.concat(...res.data.data);
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.gsz {
	background-color: #f9f9f9;
	min-height: 100vh;
	box-sizing: border-box;
	padding: 25rpx;
	.top-warp {
		display: flex;
		flex-direction: column;
		border-radius: 40rpx;
		background-color: #fff;
		.top-bottom {
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			.btn {
				padding: 25rpx;
				display: flex;
				align-items: center;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
				color: #261332;
				line-height: 40rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;
				.tb {
					margin-right: 10rpx;
					width: 38rpx;
					height: 38rpx;
				}
			}

			.lin {
				margin: 0 100rpx;
				width: 0 rpx;
				height: 32rpx;
				border: 2rpx solid #eeedef;
			}
		}
	}
	.top-box {
		margin: 0 auto;
		width: 100%;
		height: 204rpx;
		border-radius: 40rpx;
		background: url(@/static/images/gsz.png) no-repeat center / 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 50rpx;
		box-sizing: border-box;
		font-size: 24rpx;
		font-weight: 400;
		line-height: 33.6rpx;
		color: #fac6ff;
		.t {
			font-family: Bahnschrift, Bahnschrift;
			font-weight: 400;
			font-size: 72rpx;
			color: #ffffff;
			line-height: 86rpx;
			letter-spacing: 1px;
			text-align: left;
			font-style: normal;
			text-transform: none;
		}
		.btn {
			font-size: 26rpx;
			font-weight: 400;
			letter-spacing: 0rpx;
			line-height: 36.4rpx;
			color: rgba(255, 255, 255, 1);
			border: 1px solid #fff;
			padding: 10rpx 30rpx;
			border-radius: 20rpx;
		}
	}
	.bottom {
		background-color: #ffffff;
		border-radius: 20rpx;
		margin-top: 30rpx;
		padding: 20rpx;
		.item {
			display: flex;
			flex-direction: column;
			border-bottom: 2rpx solid #efefef;
			padding: 20rpx;
			.title {
				display: flex;
				justify-content: space-between;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 30rpx;
				color: #000000;
				line-height: 42rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;
				.num {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #ec5bff;
					line-height: 34rpx;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
			}
			.date {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 24rpx;
				color: #8e8e8e;
				line-height: 34rpx;
				text-align: left;
				font-style: normal;
				text-transform: none;
			}
		}
	}
}
</style>
